# 安装
# pip install flask-restful

from flask import Flask, Blueprint
from flask_restful import Api, reqparse, abort, Api, Resource

# app = Flask(__name__)

RestfulDemobp = Blueprint('restfulDemo', __name__, url_prefix='/rsf')
api = Api(RestfulDemobp)


class HelloWorld(Resource):
    def get(self):
        return {'hello': 'world'}

    def post(self):
        return {'hello': 'world', 'method': 'post'}


class HelloWorldPython(Resource):
    def get(self):
        return {'hello': 'python'}

    def post(self):
        return {'hello': 'python', 'method': 'post'}


# 根据后面的匹配规则指向制定类名
# 同名的话则按先匹配先进入原则
api.add_resource(HelloWorldPython, '/python')
api.add_resource(HelloWorld, '/hello')
# api.add_resource(HelloWorldPython, '/python')

#if __name__ == '__main__':
#    app.run(debug=True)
